Fix context progress bar not resetting after /clear command#5652
Merged
katzdave merged 4 commits intoblock:mainfrom Nov 13, 2025
Merged
Fix context progress bar not resetting after /clear command#5652katzdave merged 4 commits intoblock:mainfrom
katzdave merged 4 commits intoblock:mainfrom
Conversation
99e9c7f to
396a338
Compare
Fixes block#5651 When using /clear to reset the conversation, the context progress bar was showing the old token usage percentage instead of resetting to 0%. This was because the /clear command cleared the messages but did not reset the token count metadata stored in the session database. Changes: - Reset total_tokens, input_tokens, and output_tokens to 0 when clearing the conversation in the /clear command handler - Token counts are now properly synchronized with the cleared state Testing: - Manually tested by building and running goose-cli v1.13.0 - Verified context bar resets to 0% after /clear command - Confirmed no compilation errors with cargo check Signed-off-by: Cat Bilyeu <[email protected]>
396a338 to
f11da5c
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where the context progress bar was not resetting to 0% after using the /clear command. The issue occurred because clearing the conversation only removed messages but did not reset the token count metadata stored in the session database.
Key changes:
- Added token count reset logic to the
/clearcommand handler - Token counts (total_tokens, input_tokens, output_tokens) are now set to 0 when clearing the conversation
Improved the /clear command to maintain consistency between in-memory and database state, even if database operations fail: - Perform database operations before clearing in-memory state - Add recovery logic if token reset fails after conversation is cleared - Reset accumulated token counts (previously missed) - Clear in-memory messages only after confirming DB operations succeed This prevents inconsistent states where messages and token counts could become mismatched if database operations fail mid-execution. Addresses Co-Pilot feedback on PR block#5652 with a more robust solution that handles partial failure scenarios. Signed-off-by: Cat Bilyeu <[email protected]> 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
katzdave
reviewed
Nov 11, 2025
- Remove unnecessary comments - Keep only current token counts reset (preserve accumulated tokens for desktop view) - Remove recovery logic, just error and continue if operations fail - Add newline before "Chat context cleared" message for better formatting Signed-off-by: Cat Bilyeu <[email protected]>
katzdave
approved these changes
Nov 12, 2025
crates/goose-cli/src/session/mod.rs
Outdated
| tracing::info!("Chat context cleared by user."); | ||
| output::render_message( | ||
| &Message::assistant().with_text("Chat context cleared."), | ||
| &Message::assistant().with_text("\nChat context cleared."), |
Collaborator
There was a problem hiding this comment.
I think \n on the other end I wasn't seeing a line break before the next prompt but if this renders well can go with this too.
katzdave
added a commit
that referenced
this pull request
Nov 13, 2025
…eanup * 'main' of github.com:block/goose: (46 commits) Fix context progress bar not resetting after /clear command (#5652) docs: removing double announcements (#5714) docs: mcp sampling support (#5708) hackathon banner (#5710) Fix documentation-only change detection for push events (#5712) Added transaction commits to multi sql functions in session_manager (#5693) fix: improve and simplify tool call chain rendering (#5704) Fix: Always show autocompact threshold ui (#5701) chore: Update governance to include Discord (#5690) Ollama improvements (#5609) feat: add Supabase MCP server to registry (#5629) Unlist VS Code extension tutorials from MCP and experimental sections (#5677) fix: make image processing work in github copilot provider (#5687) fix: do not take into account gitignore in developer mcp (#5688) docs: session storage migration (#5682) New maintainers (#5685) chore: Update governance (#5660) chore(release): release version 1.14.0 (minor) (#5676) fix : action icons overlap session title in chat history (#5684) Document recent goose PRs (#5683) ...
tlongwell-block
added a commit
that referenced
this pull request
Nov 14, 2025
* origin/main: (51 commits) Compaction resiliency improvements (#5618) docs: ask goose button (#5730) Update prompt injection detection metrics (due to errors exporting to datadog) (#5692) Spence/icon2 tokyo drift (#5728) docs: logs rotation and misc updates (#5727) docs: automatic ollama model detection (#5725) Fix context progress bar not resetting after /clear command (#5652) docs: removing double announcements (#5714) docs: mcp sampling support (#5708) hackathon banner (#5710) Fix documentation-only change detection for push events (#5712) Added transaction commits to multi sql functions in session_manager (#5693) fix: improve and simplify tool call chain rendering (#5704) Fix: Always show autocompact threshold ui (#5701) chore: Update governance to include Discord (#5690) Ollama improvements (#5609) feat: add Supabase MCP server to registry (#5629) Unlist VS Code extension tutorials from MCP and experimental sections (#5677) fix: make image processing work in github copilot provider (#5687) fix: do not take into account gitignore in developer mcp (#5688) ...
wpfleger96
added a commit
that referenced
this pull request
Nov 14, 2025
* main: (65 commits) Fix: Recipes respect the quiet flag (#5743) docs: update cli commands (#5744) Run smoke tests on a free runner (#5745) faster, cheaper (pick two): improve CI workflow and switch to free github runner (#5702) Compaction resiliency improvements (#5618) docs: ask goose button (#5730) Update prompt injection detection metrics (due to errors exporting to datadog) (#5692) Spence/icon2 tokyo drift (#5728) docs: logs rotation and misc updates (#5727) docs: automatic ollama model detection (#5725) Fix context progress bar not resetting after /clear command (#5652) docs: removing double announcements (#5714) docs: mcp sampling support (#5708) hackathon banner (#5710) Fix documentation-only change detection for push events (#5712) Added transaction commits to multi sql functions in session_manager (#5693) fix: improve and simplify tool call chain rendering (#5704) Fix: Always show autocompact threshold ui (#5701) chore: Update governance to include Discord (#5690) Ollama improvements (#5609) ...
michaelneale
added a commit
that referenced
this pull request
Nov 17, 2025
* main: scan recipe for security when saving recipe (#5747) feat: trying grok for live test (#5732) Platform Extension MOIM (Minus One Info Message) (#5027) docs: remove hackathon banner (#5756) Fix: Recipes respect the quiet flag (#5743) docs: update cli commands (#5744) Run smoke tests on a free runner (#5745) faster, cheaper (pick two): improve CI workflow and switch to free github runner (#5702) Compaction resiliency improvements (#5618) docs: ask goose button (#5730) Update prompt injection detection metrics (due to errors exporting to datadog) (#5692) Spence/icon2 tokyo drift (#5728) docs: logs rotation and misc updates (#5727) docs: automatic ollama model detection (#5725) Fix context progress bar not resetting after /clear command (#5652) docs: removing double announcements (#5714) docs: mcp sampling support (#5708)
Surendhar-N-D
pushed a commit
to Surendhar-N-D/goose
that referenced
this pull request
Nov 17, 2025
Signed-off-by: Cat Bilyeu <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: David Katz <[email protected]>
arul-cc
pushed a commit
to arul-cc/goose
that referenced
this pull request
Nov 17, 2025
Signed-off-by: Cat Bilyeu <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: David Katz <[email protected]>
BlairAllan
pushed a commit
to BlairAllan/goose
that referenced
this pull request
Nov 29, 2025
Signed-off-by: Cat Bilyeu <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: David Katz <[email protected]> Signed-off-by: Blair Allan <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5651
Summary
When using /clear to reset the conversation, the context progress bar was showing the old token usage percentage instead of resetting to 0%.
This was because the /clear command cleared the messages but did not reset the token count metadata stored in the session database.
Changes:
Type of Change
AI Assistance
Testing
Related Issues
Relates to #5651
Discussion: #5651
Screenshots/Demos (for UX changes)
Before:


After:
Submitting a Recipe?
Email: